package cn.wk.controller;

import cn.wk.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 生产者
 */
@RestController
@RequestMapping("/provider/user")
public class ProviderController {
    @Autowired
    private ApplicationContext applicationContext;

    @RequestMapping("/{id}")
    private User getUser(@PathVariable Long id){
        String[] profiles = applicationContext.getEnvironment().getActiveProfiles();
        /*if(id %2 ==0){
            throw new RuntimeException("异常");
        }*/
        return new User(id,profiles[0]);
    }
}
